package com;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class MyServlet2 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //客户端和服务端编码不一致 所以会出现乱码
        //设置请求乱码
        req.setCharacterEncoding("utf-8");
        //设置响应乱码
        resp.setContentType("text/html;charset=utf-8");

        System.out.println("我该做些啥？");
        String username = req.getParameter("username");

        //完整的请求地址
        StringBuffer requestURL = req.getRequestURL();
        String requestURI = req.getRequestURI();
        resp.getWriter().write("<h1>hello"+username+"<h1>");
        String method = req.getMethod();
        System.out.println("method"+method);


    }
}
